﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Bungalow.Spider.Elements;
using Bungalow.Spider;
using Bungalow.Spider.Skins;

namespace Bungalow
{
    public partial class SpiderView : UserControl
    {
        

        private void Spider_Load(object sender, EventArgs e)
        {

        } 
        public int getWidth() {
            return this.Width;
        }
        public int getHeight() {
            return this.Height;
        }
        public void setWidth(int width) {
            this.Width = width;
        }
        public void setHeight(int height) {
            this.Height = height;
        }
        public void setBackground(Color color) {
            this.BackColor = color;
        }
        public SPSkin mSkin;
        public SpiderView()
	    {
            InitializeComponent();
		    mSkin= new SpiderDefaultSkin();
		    setBackground(mSkin.getBackgroundColor());
            this.Paint += new PaintEventHandler(SpiderView_Paint);
	    }

        void SpiderView_Paint(object sender, PaintEventArgs e)
        {
            paint(e.Graphics);
        }
	    public SPSkin getSkin()
	    {
		    return mSkin;
	    }
        public List<Spider.Elements.element> mElements = new List<Spider.Elements.element>();
        public List<Spider.Elements.element> getElements()
        {
            return this.mElements;
        }
        public void setSkin(SPSkin mSkin)
        {
            this.mSkin = mSkin;
        }
        
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            paint(e.Graphics);
        }
        public void paint(Graphics arg0)
        {
            // TODO Auto-generated method stub
            
            arg0.FillRectangle(new SolidBrush(getSkin().getBackgroundColor()), new Rectangle(0,0,this.Width,this.Height));
            //   arg0.DrawRectangle(0, 0, getWidth(), getHeight());
            if (getElements().Count > 0)
            {   
                element c = getElements()[0];




                c.setBounds(new Rectangle(0, 0, getWidth(), getHeight()));
                c.paint(arg0, new Rectangle(0, 0, getWidth(), getHeight()));

            }
        }
    }
}
